package com.xujiahao.controller;

import com.xujiahao.common.R;
import com.xujiahao.util.Main;
import com.xujiahao.util.object.Alphabetizer;
import com.xujiahao.util.object.Input;
import com.xujiahao.util.object.Output;
import com.xujiahao.util.object.Shift;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.util.ArrayList;
import java.util.List;

@RestController
//@RequestMapping("/api")
public class mainController {

    @GetMapping("/main")
    public R<List<String>> main(){
        Main mainImp = new Main();
        mainImp.input("E:\\input.txt");
        mainImp.shift();
        mainImp.alphabetizer();
        List<String> output = mainImp.output("E:\\output.txt");
        return R.success(output);
    }

    @GetMapping("/object")
    public R<List<String>> object(){
        Input input = new Input();
        input.input("E:\\input.txt");
        Shift shift = new Shift(input.getLineTxt());
        shift.shift();
        Alphabetizer alphabetizer = new Alphabetizer(shift.getKwicList());
        alphabetizer.sort();
        Output output = new Output(alphabetizer.getKwicList());
        List<String> list = output.output("E:\\output.txt");
        return R.success(list);
    }

}
